package client.comm.commlib.service

import android.app.IntentService
import android.app.Service
import android.content.Intent
import android.os.Handler
import android.os.HandlerThread
import android.os.IBinder
import android.os.Message
import client.comm.commlib.toDp

class DownLoadService : Service() {


    val mHandler: BackTaskHandler by lazy {
        val thread = HandlerThread("downloadService")
        thread.start()
        BackTaskHandler(thread.looper)
    }

    override fun onBind(intent: Intent?): IBinder? {
        return null
    }

    override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {

        intent?.apply {
            when (action) {
                BackTaskHandler.LOAD_APK -> {
                    val message = mHandler.obtainMessage(0, getStringExtra("url"))
                    mHandler.sendMessage(message)

                }

            }
        }
        return super.onStartCommand(intent, flags, startId)
    }
}